package com.itboye.hutouben.activity.qianbao;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.hutouben.R;
import com.itboye.hutouben.base.BaseActivity;
import com.itboye.hutouben.presenter.SystemMessgeAPresenter;
import com.itboye.hutouben.util.ByAlert;
import com.itboye.hutouben.util.IsUtilUid;
import com.itboye.hutouben.util.OnPasswordInputFinish;
import com.itboye.hutouben.util.PasswordView;
import com.itboye.hutouben.volley.ResultEntity;

import java.util.Observable;
import java.util.Observer;

/**
 * 记得支付密码(修改密码完成)
 *
 */
public class JiDePassTwoActivity extends BaseActivity implements Observer{
    TextView add_shap_title_tv,add_lift_tv;
    ImageView close_icon;
    SystemMessgeAPresenter presenter;
    PasswordView pwdView;// 支付密码
    String pwd;
    String newspwds;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ji_de_pass_two);
        add_shap_title_tv.setVisibility(View.GONE);
        add_lift_tv.setText(R.string.shezhi_zhifu_pass);
        pwd=getIntent().getStringExtra("paypent");

          pwdView = (PasswordView) findViewById(R.id.pwd_view);
        presenter=new SystemMessgeAPresenter(this);
        // 添加密码输入完成的响应
        pwdView.setOnFinishInput(new OnPasswordInputFinish() {
            @Override
            public void inputFinish() {
                // 输入完成后跳转
                newspwds=pwdView.getStrPassword();
                    presenter.onRememberPay(IsUtilUid.isUid(),pwd,newspwds);
                // 也就是说——>实现你的交易逻辑什么的在这里写

            }
        });
    }

    @Override
    protected void onInit() {


    }

    @Override
    protected void onReadIntent(Bundle bundle) {

    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void update(Observable observable, Object data) {
        ResultEntity entity = handlerError(data);
        if (entity != null) {
            IsUtilUid.tianjia(entity);
            if (entity.getEventType() == presenter.Remember_success) {
                ByAlert.alert(entity.getData()+"");
                finish();
                Intent sendIntent=new Intent("sendIntent");
                sendBroadcast(sendIntent);
            }
        }
    }
}
